package com.ljtxxhwj.myblob.controller;

import com.ljtxxhwj.myblob.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/users")
public class UserController {

    private final UserService userService;

    @Autowired
    public UserController(UserService userService) {
        this.userService = userService;
    }

    @PutMapping("/{userId}/name")
    public ResponseEntity<Void> updateUserName(@PathVariable Integer userId, @RequestParam String newUserName) {
        userService.updateUserName(userId, newUserName);
        return ResponseEntity.ok().build();
    }

    @PutMapping("/{userId}/password")
    public ResponseEntity<Void> updateUserPassword(@PathVariable Integer userId, @RequestParam String newUserPassword) {
        userService.updateUserPassword(userId, newUserPassword);
        return ResponseEntity.ok().build();
    }

    @PutMapping("/{userId}/picture")
    public ResponseEntity<Void> updateUserPic(@PathVariable Integer userId, @RequestParam String newUserPic) {
        userService.updateUserPic(userId, newUserPic);
        return ResponseEntity.ok().build();
    }

    @PutMapping("/{userId}/introduce")
    public ResponseEntity<Void> updateUserIntroduce(@PathVariable Integer userId, @RequestParam String newUserIntroduce) {
        userService.updateUserIntroduce(userId, newUserIntroduce);
        return ResponseEntity.ok().build();
    }

    @PutMapping("/{userId}/phone")
    public ResponseEntity<Void> updateUserPhone(@PathVariable Integer userId, @RequestParam String newUserPhone) {
        userService.updateUserPhone(userId, newUserPhone);
        return ResponseEntity.ok().build();
    }

    @PutMapping("/{userId}/email")
    public ResponseEntity<Void> updateUserEmail(@PathVariable Integer userId, @RequestParam String newUserEmail) {
        userService.updateUserEmail(userId, newUserEmail);
        return ResponseEntity.ok().build();
    }
}
